#pragma once
#include <myFs/bitmap.h>
#include <myFs/fscomponent.h>
#include <spdlog/spdlog.h>

namespace myFs {
namespace basic {
using namespace spdlog;
class Buf {
   public:
    Buf(Inode& inode, Bitmap* pBlockbitmap);

    size_t size() const;

    size_t read(char* dst, size_t nbytes, size_t off);
    size_t write(char const* src, size_t nbytes, size_t off);

   private:
    char& at(size_t i);
    size_t allocBlock();
    char* convertToAddr(size_t bnum) const;

   private:
    Inode& m_inode;
    Bitmap* m_pBitmap;
};
}  // namespace basic

}  // namespace myFs